﻿using Microsoft.Extensions.Logging;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WebApi.Core.Common
{
    public  static class LoggerHelper
    { 
        public static void LogSql(string sql, SugarParameter[] parameters)
        {
            var loggerFactory = LoggerFactory.Create(builder =>
                builder.AddConsole().SetMinimumLevel(LogLevel.Information));
            var logger = loggerFactory.CreateLogger("SqlSugar");
            logger.LogInformation("SQL: {sql} \nParameters: {parameters}",
                sql,
                string.Join(", ", parameters.Select(p => $"{p.ParameterName}={p.Value}")));
        }
    }
}
